﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:System.Windows.Controls.WpfPropertyGrid"
  xmlns:design="clr-namespace:System.Windows.Controls.WpfPropertyGrid.Design"
  xmlns:controls="clr-namespace:System.Windows.Controls.WpfPropertyGrid.Controls">

  <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
  <local:MultiBooleanToVisibilityConverter x:Key="multiBooleanToVisibilityConverter"/>

  <Style TargetType="{x:Type local:PropertyGrid}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:PropertyGrid}">
          <DockPanel LastChildFill="True" Background="{TemplateBinding Background}">
            <controls:SearchTextBox DockPanel.Dock="Top"
                                    Text="{Binding Path=PropertyFilter, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
                                    Visibility="{TemplateBinding PropertyFilterVisibility}" />

            <!--<Border DockPanel.Dock="Bottom" Height="70" Margin="2">-->
              <!--<TextBlock x:Name="DescriptionBlock"  Margin="5" Foreground="DimGray" TextWrapping="Wrap" TextTrimming="WordEllipsis" Text="{TemplateBinding CurrentDescription}"/>-->
              <!--<TextBox x:Name="DescriptionBlock"  TextWrapping="Wrap" IsReadOnly="True" Text="{TemplateBinding CurrentDescription}"/>
            </Border>-->
            <ContentPresenter FocusManager.IsFocusScope="True" ContentSource="Layout"/>

          </DockPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type local:PropertyContainer}" TargetType="{x:Type local:PropertyContainer}">
    <Setter Property="Visibility">
      <Setter.Value>
        <MultiBinding Converter="{StaticResource multiBooleanToVisibilityConverter}" UpdateSourceTrigger="PropertyChanged" Mode="OneWay">
          <Binding Path="IsBrowsable"/>
          <Binding Path="MatchesFilter"/>
        </MultiBinding>
      </Setter.Value>
    </Setter>
    <Setter Property="ToolTip" Value="{Binding Entry.ToolTip, RelativeSource={RelativeSource Self}}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid Margin="4">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" SharedSizeGroup="PropertyNameSizeGroup"/>
              <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <design:PropertyNameTextBlock Grid.Column="0" Margin="0,0,8,0"
                                          Text="{Binding DisplayName, Mode=OneTime}"
                                          Foreground="{Binding ItemsForeground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PropertyGrid}}}"
                                          />
            <design:PropertyEditorContentPresenter Grid.Column="1" VerticalAlignment="Center"/>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type local:CategoryContainer}" TargetType="{x:Type local:CategoryContainer}">
    <Setter Property="Visibility">
      <Setter.Value>
        <MultiBinding Converter="{StaticResource multiBooleanToVisibilityConverter}" UpdateSourceTrigger="PropertyChanged" Mode="OneWay">
          <Binding Path="IsBrowsable"/>
          <Binding Path="HasVisibleProperties"/>
          <Binding Path="MatchesFilter"/>
        </MultiBinding>
      </Setter.Value>
    </Setter>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Expander Header="{Binding Name}" IsExpanded="{Binding Entry.IsExpanded, RelativeSource={RelativeSource TemplatedParent}}">
            <design:CategoryEditorContentPresenter />
          </Expander>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>